<template>
  <div style="height:50px;width:100vw; line-height: 50px;border-bottom: solid #2c3e50;display: flex;position: fixed;background-color: white">
    <div style="width: 200px;padding-left: 30px;font-weight: bold;color: cornflowerblue">欢迎！{{administrator.username}}</div>
    <div style="flex: 1"></div>
    <div style="width: 100px;padding-top: 15px">
      <el-dropdown>
        <span class="el-dropdown-link">
          {{ administrator.username }}<i class="el-icon-arrow-down el-icon--right"></i>
          <el-icon class="el-icon">
           <arrow-down/>
          </el-icon>
        </span>
        <template #dropdown>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item @click="clickPerson" >个人信息</el-dropdown-item>
            <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
  export default {
    name:"Header",
    data(){
      return{
        administrator:JSON.parse(sessionStorage.getItem("administrator"))
      }
    },
    created() {
      if(sessionStorage.getItem("administrator")===null){
        this.$router.push("/login")
      }
    },
    methods:{
      clickPerson(){
        this.$router.push("/settings")
      },
      logout(){
        sessionStorage.clear()
        this.$router.push("/login")
      }
    }
  }
</script>

<style scoped>


</style>

